package com.example.demo.model.mnt;
import com.example.demo.handler.OperationHandlerImpl2;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_erupt.RowOperation;
import xyz.erupt.annotation.sub_erupt.Tpl;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.ViewType;
import xyz.erupt.annotation.sub_field.sub_edit.*;
import xyz.erupt.core.annotation.EruptDataSource;
import xyz.erupt.jpa.model.BaseModel;
import xyz.erupt.upms.handler.DictChoiceFetchHandler;
import xyz.erupt.upms.handler.SqlChoiceFetchHandler;

import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;

@EruptDataSource("mnt")
@Erupt(name = "mnt_config" ,power = @Power(add = true, delete = false, edit = true,export = true),
        rowOperation = {
        @RowOperation(
                operationHandler = OperationHandlerImpl2.class,
                mode = RowOperation.Mode.SINGLE,
                title = "单行操作"),
        @RowOperation(type = RowOperation.Type.TPL,
                        mode = RowOperation.Mode.MULTI,
                        tpl = @Tpl(path = "/tpl/operation.ftl", engine = Tpl.Engine.FreeMarker),
                        title = "自定义模板",
                        icon = "fa fa-pagelines"),
        @RowOperation(type = RowOperation.Type.TPL,
                        mode = RowOperation.Mode.SINGLE,
                        tpl = @Tpl(path = "/tpl/operation.ftl", engine = Tpl.Engine.FreeMarker),
                        title = "自定义模板",
                        icon = "fa fa-pagelines")})
@Entity
@Table(name = "mnt_config")
public class NtConfig extends BaseModel {


	/**
	 * 名称
	 */
  @EruptField(
          views = @View(
                  title = "商品名称", sortable = true
          ),
          edit = @Edit(
                  title = "商品名称",
                  type = EditType.INPUT, search = @Search, notNull = true,
                  inputType = @InputType
          )
  )

  private String name;

	/**
	 * 编码
	 */
//  @EruptField(
//          views = @View(
//                  title = "编码", sortable = true
//          ),
//          edit = @Edit(
//                  title = "编码",
//                  type = EditType.INPUT, search = @Search, notNull = true,
//                  inputType = @InputType
//          )
//  )

  @EruptField(
          views = @View(title = "动态下拉列表"),
          edit = @Edit(
                  search = @Search,
                  title = "通过SQL获取下拉列表",
                  type = EditType.CHOICE,
                  desc = "动态下拉列表",
                  choiceType = @ChoiceType(
                          fetchHandler = SqlChoiceFetchHandler.class,
                          fetchHandlerParams = "select id,name from e_upms_menu"
                  ))
  )
  private String code;

	/**
	 * 值
	 */
//  @EruptField(
//          views = @View(
//                  title = "值", sortable = true
//          ),
//          edit = @Edit(
//                  title = "值",
//                  type = EditType.INPUT, search = @Search, notNull = true,
//                  inputType = @InputType
//          )
//  )
  @EruptField(
          views = @View(title = "字典值"),
          edit = @Edit(
                  search = @Search,
                  title = "字典值", type = EditType.CHOICE, desc = "动态获取字典项的值",
                  choiceType = @ChoiceType(
                          fetchHandler = DictChoiceFetchHandler.class,
                          fetchHandlerParams = "system" //字典编码，通过字典编码获取字典项列表
                  ))
  )
  private String value;

	/**
	 * 是否是系统参数（Y-是，N-否）
	 */
  @EruptField(
          views = @View(
                  title = "是否是系统参数", sortable = true
          ),
          edit = @Edit(
                  title = "是否是系统参数",
                  type = EditType.INPUT, search = @Search, notNull = true,
                  inputType = @InputType
          )
  )
  private String mntFlag;

	/**
	 * 备注
	 */
  @EruptField(
          views = @View(
                  title = "备注", sortable = true
          ),
          edit = @Edit(
                  title = "备注",
                  type = EditType.INPUT, search = @Search, notNull = true,
                  inputType = @InputType
          )
  )
  private String remark;

	/**
	 * 状态（字典 0正常 1停用 2删除）
	 */
  @EruptField(
          views = @View(
                  title = "商品状态", sortable = true
          ),
          edit = @Edit(title = "商品de状态", notNull = true, type = EditType.CHOICE,
                  choiceType = @ChoiceType(vl = {
                          @VL(value = "0", label = "正常"),
                          @VL(value = "1", label = "一级推荐"),
                          @VL(value = "2", label = "二级推荐"),
                          @VL(value = "3", label = "三级推荐")
                  }), search = @Search(vague = true)
          )
  )
  private String status;

	/**
	 * 常量所属分类的编码，来自于“常量的分类”字典
	 */
  @EruptField(
          views = @View(
                  title = "常量所属分类的编码", sortable = true
          ),
          edit = @Edit(
                  title = "常量所属分类的编码",
                  type = EditType.INPUT, search = @Search, notNull = true,
                  inputType = @InputType
          )
  )
  private String groupCode;





  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }


  public String getCode() {
    return code;
  }

  public void setCode(String code) {
    this.code = code;
  }


  public String getValue() {
    return value;
  }

  public void setValue(String value) {
    this.value = value;
  }


  public String getMntFlag() {
    return mntFlag;
  }

  public void setMntFlag(String mntFlag) {
    this.mntFlag = mntFlag;
  }


  public String getRemark() {
    return remark;
  }

  public void setRemark(String remark) {
    this.remark = remark;
  }


  public String getStatus() {
    return status;
  }

  public void setStatus(String status) {
    this.status = status;
  }


  public String getGroupCode() {
    return groupCode;
  }

  public void setGroupCode(String groupCode) {
    this.groupCode = groupCode;
  }



}
